package uml.view.factory;

import uml.eventsystem.events.UMLEventId;
import uml.objects.UMLObject;
import uml.view.ClassFormatter_View;
import uml.view.UMLContainerView;

/**
 * A factory that creates the formatters for UML view objects. This class uses 
 * the <tt>ContainerFactory</tt> to each formatter's container. Each method in 
 * this class returns a general formatter object; the exact type is indicated 
 * by the method signature.
 * 
 * @author Neil Obetz
 *
 */

public final class ClassFormatterFactory
{
	
	public static UMLObject createObject (UMLEventId eventId)
	{
		ClassFormatter_View formatter = new ClassFormatter_View ();
		
		if (eventId.equals (UMLEventId.MAKE_CLASS))
		{
			formatter = createClassFormatter ();
		}
		else if (eventId.equals (UMLEventId.MAKE_INTERFACE))
		{
			formatter = createInterfaceFormatter ();
		}
		else if (eventId.equals (UMLEventId.MAKE_CIRCLE_INTERFACE))
		{
			formatter = createInterfaceFormatter ();
		}
		else if (eventId.equals (UMLEventId.MAKE_NOTE))
		{
			formatter = createNoteFormatter ();
		}
		else if (eventId.equals (UMLEventId.MAKE_PACKAGE))
		{
			formatter = createInterfaceFormatter ();
		}
		else
		{
			System.out.println ("Not a valid id. Returning a default value.");
		}
		
		return formatter;
	}
	
	
	/**
	 * Creates a formatter object for a class view.
	 * 
	 * @return the class formatter
	 */
	
	public static ClassFormatter_View createClassFormatter ()
	{
		UMLContainerView view = ContainerFactory.createClassView ();
		ClassFormatter_View formatter = new ClassFormatter_View ();
		formatter.setContainer (view);
		formatter.setFontPlain ();
		return formatter;
	}

	/**
	 * Creates a formatter for a fully implemented interface.
	 * 
	 * @return the interface formatter
	 */
	
	public static ClassFormatter_View createInterfaceFormatter ()
	{
		UMLContainerView view = ContainerFactory.createInterfaceView ();
		ClassFormatter_View formatter = new ClassFormatter_View ();
		formatter.setContainer (view);
		formatter.setFontItalic ();
		return formatter;
	}

	
	
	/**
	 * Creates a formatter for a UML note.
	 * 
	 * @return the note formatter
	 */
	
	public static ClassFormatter_View createNoteFormatter ()
	{
		UMLContainerView view = ContainerFactory.createNoteView ();
		ClassFormatter_View formatter = new ClassFormatter_View ();
		formatter.setContainer (view);
		formatter.setFontPlain ();
		return formatter;
	}
	
	/**
	 * Creates a formatter for UML circle interface.
	 * 
	 * @return the interface formatter
	 */
	
	public static ClassFormatter_View createCircleInterfaceFormatter ()
	{
		UMLContainerView view = ContainerFactory.createCircleInterfaceView ();
		ClassFormatter_View formatter = new ClassFormatter_View ();
		formatter.setContainer (view);
		formatter.setFontItalic ();
		return formatter;
	}
	
	/**
	 * Creates a formatter for a package
	 * 
	 * @return the package formatter
	 */

	public static ClassFormatter_View createPackageFormatter ()
	{
		UMLContainerView view = ContainerFactory.createPackageView ();
		ClassFormatter_View formatter = new ClassFormatter_View ();
		formatter.setContainer (view);
		formatter.setFontBold ();
		return formatter;
	}

}
